package com.bw.sms.service.imp;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.core.creditStatus.DeleteStatus;
import com.bw.core.vo.RiskOrderVO;
import com.bw.core.vo.SystemInfromVo;
import com.bw.sms.mapper.TbSmsLogMapper;
import com.bw.sms.mapper.TbSysMsgLogMapper;
import com.bw.sms.pojo.SendcaptchaVo;
import com.bw.sms.pojo.TbSysMsgLog;
import com.bw.sms.service.TbSysMsgLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Properties;

/**
 * <p>
 * 系统消息记录表 服务实现类
 * </p>
 *
 * @author lv
 * @since 2021-03-23
 */
@Service
public class TbSysMsgLogServiceImpl extends ServiceImpl<TbSysMsgLogMapper, TbSysMsgLog> implements TbSysMsgLogService {

    @Override
    public void registerSize(String msg){
        JSONObject jsonObject = JSONObject.parseObject(msg);
        SendcaptchaVo sendcaptchaVo = JSONObject.toJavaObject(jsonObject, SendcaptchaVo.class);

        Properties prop = new Properties();
        try {
            prop.load(new FileInputStream("credit-sms/src/main/resources/bootstrap.yml"));
            String merId = (String) prop.get("merId");
            String appSercret = (String) prop.get("appSercret");

            HashMap<String, Object> map = new HashMap<>();
            map.put("code",sendcaptchaVo.getYzm());
            map.put("bindCardId",sendcaptchaVo.getPhone());
            map.put("merId",merId);
            map.put("sign",appSercret);
            String post = HttpUtil.post("http://localhost:8080/api/common/bindCardConfirm", map);
            System.out.println("验证码消息发送："+post);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void bankcardsize(String msg) throws Exception {

    }
}
